<html><head><title>SetGadgetItemData</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="4">SetGadgetItemData()</font></b></p>
<p><b>Syntax</b></p><blockquote>
<font color="#006666"><b>SetGadgetItemData</b></font>(#Gadget, Item, Value)</blockquote>

</blockquote>
<b>Description</b><br><blockquote>

Stores the given value with the specified gadget item. This value can later be read with the <a href="getgadgetitemdata.html">GetGadgetItemData()</a> 
function. This allows to associate a custom value with the items of a gadget. 

</blockquote><p><b>Parameters</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>#Gadget</i></td>
<td width="90%"> 
The gadget to use. 

</td></tr>
<tr><td><i>Item</i></td>
<td> 
The item to use. The first item in the gadget has index 0. 

</td></tr>
<tr><td><i>Value</i></td>
<td> 
The value to set. 

</td></tr>
</table>
</blockquote><p><b>Return value</b></p><blockquote>
None.


</blockquote><p><b>Remarks</b></p><blockquote>

The set value will remain with the item, even 
if the item changes its index (for example because other items were deleted). 
<br>
<br>
This function works with the following gadgets: 
<br>
- <a href="comboboxgadget.html">ComboBoxGadget()</a> 
<br>
- <a href="listicongadget.html">ListIconGadget()</a> 
<br>
- <a href="listviewgadget.html">ListViewGadget()</a> 
<br>
- <a href="panelgadget.html">PanelGadget()</a> 
<br>
- <a href="treegadget.html">TreeGadget()</a> 


</blockquote><p><b>Example</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <font color="#006666">; This code uses SetGadgetItemData to store the original position</font>
  <font color="#006666">; of each item to later know it, even if the items index changed.</font>
  <font color="#006666">;</font>
  <b><font color="#006666">If</font></b> <font color="#006666">OpenWindow</font>(0, 0, 0, 280, 250, "SetGadgetItemData", <font color="#924B72">#PB_Window_SystemMenu</font> | <font color="#924B72">#PB_Window_ScreenCentered</font>)
<font color="#006666">    ButtonGadget</font>(0,  10, 10, 80, 20, "Add")
<font color="#006666">    ButtonGadget</font>(1, 100, 10, 80, 20, "Remove")
<font color="#006666">    ButtonGadget</font>(2, 190, 10, 80, 20, "Test")
<font color="#006666">    ListViewGadget</font>(3, 10, 40, 260, 200)
    <b><font color="#006666">For</font></b> i = 0 <b><font color="#006666">To</font></b> 10
<font color="#006666">      AddGadgetItem</font>(3, i, "Old Item "+<font color="#006666">Str</font>(i))
<font color="#006666">      SetGadgetItemData</font>(3, i, i)
    <b><font color="#006666">Next</font></b> i

    <b><font color="#006666">Repeat</font></b>
      Event =<font color="#006666"> WaitWindowEvent</font>()
      <b><font color="#006666">If</font></b> Event = <font color="#924B72">#PB_Event_Gadget</font>
        item =<font color="#006666"> GetGadgetState</font>(3)

        <b><font color="#006666">Select</font></b> <font color="#006666">EventGadget</font>()
          <b><font color="#006666">Case</font></b> 0 <font color="#006666">; Add</font>
<font color="#006666">            AddGadgetItem</font>(3, item, "New Item")
            <b><font color="#006666">If</font></b> item &#060;&#062; -1
<font color="#006666">              SetGadgetItemData</font>(3, item, -1)
            <b><font color="#006666">Else</font></b>
<font color="#006666">              SetGadgetItemData</font>(3,<font color="#006666"> CountGadgetItems</font>(3)-1, -1)
            <b><font color="#006666">EndIf</font></b>

          <b><font color="#006666">Case</font></b> 1 <font color="#006666">; Remove</font>
            <b><font color="#006666">If</font></b> item &#060;&#062; -1
<font color="#006666">              RemoveGadgetItem</font>(3, item)
            <b><font color="#006666">EndIf</font></b>

          <b><font color="#006666">Case</font></b> 2 <font color="#006666">; Test</font>
            <b><font color="#006666">If</font></b> item &#060;&#062; -1
              value =<font color="#006666"> GetGadgetItemData</font>(3, item)
              <b><font color="#006666">If</font></b> value = -1
<font color="#006666">                MessageRequester</font>("", "Its a new item.")
              <b><font color="#006666">Else</font></b>
<font color="#006666">                MessageRequester</font>("", "It was item number "+<font color="#006666">Str</font>(value))
              <b><font color="#006666">EndIf</font></b>
            <b><font color="#006666">EndIf</font></b>

        <b><font color="#006666">EndSelect</font></b>
      <b><font color="#006666">EndIf</font></b>
    <b><font color="#006666">Until</font></b> Event = <font color="#924B72">#PB_Event_CloseWindow</font>
  <b><font color="#006666">EndIf</font></b>
</font></pre>

</blockquote><p><b>See Also</b></p><blockquote>

<a href="getgadgetitemdata.html">GetGadgetItemData()</a>, <a href="getgadgetdata.html">GetGadgetData()</a>, <a href="setgadgetdata.html">SetGadgetData()</a> 

</Blockquote><p><b>Supported OS </b><Blockquote>All</Blockquote></p><center><- <a href=setgadgetitemcolor.html>SetGadgetItemColor()</a> - <a href=index.html>Gadget Index</a> - <a href=setgadgetitemimage.html>SetGadgetItemImage()</a> ->

</body></html>